package dao.impl;

import dao.UserDao;
import org.apache.ibatis.session.SqlSession;
import pojo.User;
import util.MyBatisUtil;

import java.util.List;

public class UserDaoImpl implements UserDao {
  UserDao userDao=new UserDaoImpl();
  @Override
  public int addUser(User user) {
      SqlSession session = MyBatisUtil.getSession();
      int result =session.getMapper(UserDao.class).addUser(user);
      //提交事务
      session.commit();
      return result;

  }
  public List<User> findAll(User user) {
      //util工具类简化代码
      return MyBatisUtil.getSession().getMapper(UserDao.class).findAll(user);
  }

    @Override
    public User findById(Integer id) {
        return MyBatisUtil.getSession().getMapper(UserDao.class).findById(id);
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public int deleteUserById(Integer id) {
        return 0;
    }


}
